#include "stm32f10x.h"
#include "rtthread.h"


void portaInit(){
	//void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct);
	
	RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOD,ENABLE);
	
	GPIO_InitTypeDef GPIO_InitStruct;
	GPIO_InitStruct.GPIO_Pin = GPIO_Pin_2;
	GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
	GPIO_InitStruct.GPIO_Speed = GPIO_Speed_10MHz;
	
	GPIO_Init(GPIOD,&GPIO_InitStruct);
	
}

void task1(void *p){
		
	portaInit();
	while(1){		 
			rt_thread_mdelay(1000);
			GPIOD->ODR ^= GPIO_Pin_2;		
	}
}

int main(){
	
	rt_thread_t id = rt_thread_create("hello",task1,RT_NULL,128,RT_THREAD_PRIORITY_MAX-1,12);

	rt_thread_startup(id);


	while (1)
	{
		/* code */
		rt_thread_mdelay(1000);
		
	}	
	
	return 0;
}

